<%@page import="constant.Constant"%>
<%@page import="net.smartam.leeloo.common.OAuth"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Start to get resource</title>
<link rel="stylesheet" type="text/css" href="css/common.css">

</head>
<body>

<%
	String post_url = request.getParameter(Constant.SYNC_REDIRECT_URI);
	if(post_url==null)
		post_url = Constant.DEFAULT_URL_CLIENT;
	String access_token = request.getParameter(OAuth.OAUTH_ACCESS_TOKEN);
	//if(access_token==null) 
	//	access_token ="";
%>


<form method='post' action='<%=post_url%>?
	&<%=OAuth.OAUTH_REDIRECT_URI%>=Application.jsp
	&<%=OAuth.OAUTH_RESPONSE_TYPE%>=<%=net.smartam.leeloo.common.message.types.ResponseType.CODE.toString()%>
	'>
	
<table align=center style="margin-top:100px;">
	<tbody>
	<tr>
		<td colspan=2>
			<p>You can try to access the resource <%if(access_token!=null){%>with Token <%}%>now.</p>
		</td>
	</tr>
	<tr>
		<td colspan=2>
			&nbsp;
		</td>
	</tr>
	
	<tr>
		<td>
			Server  &nbsp;&nbsp;
		</td>
		<td>
			<select name='<%=Constant.SYNC_SERVER%>' >
				<option value='<%=Constant.HOST_AWS%>'>AWS</option>
				<option value='<%=Constant.HOST_LOCAL%>'>Local</option>
			</select>
		</td>
	</tr>

	<tr>
		<td>
			Please input client id  &nbsp;&nbsp;
		</td>
		<td>
			<input value='riptide_client_id' size=40 name='<%=OAuth.OAUTH_CLIENT_ID%>' type=text>
		</td>
	</tr>
	<tr>
		<td>
			Please input client secret  &nbsp;&nbsp;
		</td>
		<td>
			<input value='d58f814bd3ab9128ea5f1ea5264c5f' size=40 name='<%=OAuth.OAUTH_CLIENT_SECRET%>' type=text>
		</td>
	</tr>
	<%if(access_token!=null && !"".equals(access_token)){%>
	<tr>
		<td>
			Your access token  &nbsp;&nbsp;
		</td>
		<td>
			<textarea cols=50 rows=10 name='<%=OAuth.OAUTH_ACCESS_TOKEN%>' type=text readonly><%=access_token%>
			</textarea>
		</td>
	</tr>
	<%}else{ %>
	<tr>
		<td>
			Domain  &nbsp;&nbsp;
		</td>
		<td>
			<select name='<%=Constant.SYNC_AP%>' >
				<option value='<%=Constant.AP_HP%>'>HP</option>
				<option value='<%=Constant.AP_OTHER%>'>Other domain</option>
			</select>
		</td>
	</tr>	
	<%} %>
	<tr>
		<td colspan=2>
			&nbsp; <input type=hidden name ='<%=Constant.SYNC_CALLBACKURI%>' value ='http://<%=request.getRemoteHost()%>:8080/<%=request.getRequestURI()%>'>
			&nbsp; <input type=hidden name ='<%=Constant.SYNC_LOCAL_URL_AP_OTHER%>' value ='http://<%=request.getRemoteHost()%>:8080/<%=Constant.DEFAULT_AUTHSERVER%>'>
			&nbsp; <input type=hidden name ='<%=Constant.SYNC_AWS_URL_AP_OTHER%>' value ='http://demooauthmonkauthn.elasticbeanstalk.com/<%=Constant.DEFAULT_URL_AUTHSERVER%>'>
		</td>
	</tr>
	<tr>
		<td>	
			<input type=submit value='Access Resource...'>
		</td>
	</tr>
	</tbody>
</table>	
</form>
</body>
</html>